class Singleton {
  // 单例类只有一个实例对象
  private static instance: Singleton;
  public name: string;

  // 该单例对象必须由单例类自行创建
  private constructor() {
    this.name = "单例模式";
  }

  // 单例类对外提供一个访问该单例的全局访问点
  static getInstanace(): Singleton {
    if (this.instance === null) {
      this.instance = new Singleton();
    }
    return this.instance;
  }
}

const ins1 = Singleton.getInstanace();
const ins2 = Singleton.getInstanace();

console.log("ins1===ins2", ins1 === ins2);
